home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
os2
/
srefv112.zip
/
SREFPRC1.ZIP
/
OPENREAD.SRF
< prev
next >
Wrap
Text File
|
1996-05-10
|
2KB
|
68 lines
/* ----------------------------------------------------------------------- */
/* OPEN_READ: keep trying to open a file (for msec seconds
. astatus=open_read(afile,max_seconds)
. If success, astatus > 0 = # seconds it took
. If failure, astatus=-1 (no such file) or -2 (could not open)
*/
/* ----------------------------------------------------------------------- */
sref_open_read:
parse upper arg afile , msec , howopen .
debug=0
howopen=translate(howopen)
if afile=0 | afile="" then do
if debug=1 then say "OPEN_READ: No file name provided "
return -1 /*no such file flat */
end
/* DISALLOW wildcarded files (they cause trouble below */
if pos('*',afile)>0 | pos('?',afile)>0 then do
if debug=1 then say "OPEN_READ: No wildcards allowed "
return -1
end
isfile=stream(afile,'c','query exists') ;
if howopen="NEW" then do
if isfile="" then
isfile=afile
else do
if debug=1 then say "OPEN_READ: NEW file already exists "
return -1
end /* Do */
end
else do
if isfile="" then do
if debug=1 then say 'OPEN_READ: Could not find ' afile
return -1 /*no such file */
end
end
sec1=time('RESET')
foy=time('ELAPSED')
do until time('ELAPSED') > msec
select
when howopen='BOTH' then
inuse=stream(isfile,'c','open')
when howopen='WRITE'| howopen="NEW" then do
inuse=stream(isfile,'c','open write')
end
otherwise do
inuse=stream(isfile,'c','open read')
end
end
if inuse<>'READY:' then do
wait seconds 1 /* wait a second, and try again */
iterate
end
/* Else, it's openable */
gog=time('ELAPSED')
return gog+0.01
end
if debug=1 then say " OPEN_READ: no time "
return -2 /* could not open in alloted time */